<?php
use App\Admin\Eloquent\Role;
use App\Admin\Eloquent\User;
namespace App\Admin\Eloquent;
/**
 * 项目分润记录
 */
class ProjectProfit extends Model
{
  protected $fillable = ['sn','project_id','user_id','user_name', 'role_slug','project_user_id', 'money','pay_time','status','input_time','type'];
  public $timestamps = false;
  public static function page_query(array $args,int $pagesize=15){
  	$query = ProjectProfit::where('project_id','=',$args['project_id']);

    if(isset($args['user_name']) && !empty($args['user_name'])){
      $query->where('user_name','like','%'.$args['user_name'].'%');
    }
  	return $query->orderBy('id', 'asc')->paginate($pagesize);
  }
  public function role(){
  	return Role::find($this->role_id);
  }
  public function user(){
  	return User::find($this->user_id);
  }
}